/**
 * 
 */
package com.yst.metho.web.application.connector;

import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;

import javax.ejb.CreateException;
import javax.ejb.EJBException;
import javax.ejb.FinderException;
import javax.ejb.RemoveException;
import javax.naming.NamingException;

import com.yst.metho.web.application.SuiviProdApp;
import com.yst.metho.web.application.interfaces.IModuleController;
import com.yst.metho.web.application.pointage.MyActivityView;
import com.yst.metho.web.application.pointage.PointageView;
import com.yst.metho.web.application.project.AdminProjectView;
import com.yst.metho.web.application.projectversion.ProjectDetailsView;
import com.yst.metho.web.application.rights.AdminRightView;
import com.yst.metho.web.application.team.AdminTeamView;
import com.yst.metho.web.application.user.AdminUserView;
import com.yst.metho.web.application.utils.ExceptionMgt;
import com.yst.metho.web.application.utils.Locator;
import com.yst.metho.web.application.vacationday.AdminVacationView;
import com.yst.suivi.data.project.Project;
import com.yst.suivi.data.user.UserUtil;

/**
 * @author perso
 * 
 */
public class Module implements IModuleController
{

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.yst.metho.web.application.interfaces.IModuleController#getItemViews()
	 */
	public List getItemViews()
	{
		ArrayList views = new ArrayList();
		views.add(new PointageView());
		views.add(new MyActivityView());
		// ajout de tous les projets
		try
		{
			Collection existingPrj = Locator.getAssignationView().getProjectFor(UserUtil.getLocalHome().findByLogin(SuiviProdApp.getApp().getLoggedUser()));
			Iterator it = existingPrj.iterator();
			while (it.hasNext())
			{
				views.add(new ProjectDetailsView((Project) it.next()));
			}
		}
		catch (NamingException e)
		{
			ExceptionMgt.manage(e);
		}
		catch (FinderException e)
		{
			ExceptionMgt.manage(e);
		}
		catch (CreateException e)
		{
			ExceptionMgt.manage(e);
		}
		catch (EJBException e)
		{
			ExceptionMgt.manage(e);
		}
		catch (RemoveException e)
		{
			ExceptionMgt.manage(e);
		}
		catch (SQLException e)
		{
			ExceptionMgt.manage(e);
		}
		// Administration part
		views.add(new AdminUserView());
		views.add(new AdminProjectView());
		views.add(new AdminVacationView());
		views.add(new AdminRightView());
		views.add(new AdminTeamView());
		return views;
	}

}
